{{define "role/list.html"}}

<!DOCTYPE html>
<html>
	<head>
        {{template "header"}}
	</head>

	<body>
		<div class="weadmin-nav">
			<span class="layui-breadcrumb">
        <a href="/welcome">首页</a>
        <a href="/admin/role/list">角色管理</a>
        <a><cite>角色列表</cite></a>
      </span>
			<a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
				<i class="layui-icon" style="line-height:30px">ဂ</i></a>
		</div>
		<div class="weadmin-body">
			<div class="layui-row">
				<form id="roleQueryForm" class="layui-form layui-col-md12 we-search" method="get" action="/admin/role/list">
					<div class="layui-inline">
						<input type="text" name="qrolename" placeholder="角色名称" autocomplete="off" class="layui-input" value="{{ .qrolename }}">
					</div>
					<button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
				</form>
			</div>
			<div class="layui-btn-container">
				<button class="fr layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
				<button class="fr layui-btn" onclick="WeAdminEdit('添加角色','/admin/role/add','addRoleLayer')"><i class="layui-icon"></i>添加</button>
			</div>
			<table class="layui-table">
				<thead>
					<tr>
						<th>
							<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
						</th>
						<th>序号</th>
						<th>角色名称</th>
						<th>添加时间</th>
						<th>状态</th>
						<th width="220">操作</th>
					</tr>
				</thead>
				<tbody>
                    {{ range $idx, $v := .dataList }}
					<tr>
						<td>
							<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="{{$v.Id}}"><i class="layui-icon">&#xe605;</i></div>
						</td>
						<td>{{getSerialNum $idx}}</td>
						<td>{{$v.Rolename}}</td>
						<td>{{fmtYmd $v.Created}}</td>
						<td>{{if $v.State}}已启用{{else}}已禁用{{end}}</td>
						<td class="text-center">
							<a title="编辑" onclick="WeAdminShow('编辑','/admin/role/edit/{{$v.Id}}')" href="javascript:void(0);">
								<i class="layui-icon">&#xe642;</i>
							</a>
							&nbsp;&nbsp;
							<a title="关联权限" onclick="WeAdminShow('关联权限','/admin/role/authorizeFunc/{{$v.Id}}')" href="javascript:void(0);">
								<i class="layui-icon">&#xe672;</i>
							</a>
							&nbsp;&nbsp;
							<a title="授权用户" onclick="WeAdminShow('授权用户','/admin/role/authorizeUser/{{$v.Id}}')" href="javascript:void(0);">
								<i class="layui-icon layui-icon-user"></i>
							</a>
							&nbsp;&nbsp;

							{{if $v.State}}
							<a onclick="ajaxPatch('/admin/role/eord/{{$v.Id}}/0','是否确认禁用该角色?',roleRefreshForm)" href="javascript:void(0);" title="禁用">
								<i class="layui-icon">&#xe651;</i>
							</a>
							{{else}}
							<a onclick="ajaxPatch('/admin/role/eord/{{$v.Id}}/1','是否确认启用该角色?',roleRefreshForm)" href="javascript:void(0);" title="启用">
								<i class="layui-icon">&#xe652;</i>
							</a>
							{{end}}

							&nbsp;&nbsp;
							<a title="删除" onclick="ajaxDelete('/admin/role/del/{{$v.Id}}',roleRefreshForm)" href="javascript:void(0);">
								<i class="layui-icon">&#xe640;</i>
							</a>
						</td>
                    </tr>
                    {{end}}
				</tbody>
			</table>
			<div class="fr">
				{{._page.PageHtml}}
			</div>
		</div>
		<div id="_flashmsg_" style="display: none;">{{range .flashmsg}}{{.}}{{end}}</div>
    </body>

    {{template "jsfile"}}
	<script type="text/javascript">
		function roleRefreshForm(){
			location.replace(location.href);
		}

		layui.extend({
			admin: '/static/js/admin',
		});
		layui.use(['jquery', 'form', 'element', 'admin', 'carousel'], function() {
			var element = layui.element,
				$ = layui.jquery,
				carousel = layui.carousel,
				form = layui.form,
				admin = layui.admin;
			//建造实例
			carousel.render({
				elem: '.weadmin-shortcut'
				,width: '100%' //设置容器宽度
				,arrow: 'none' //始终显示箭头
				,trigger: 'hover'
				,autoplay:false
			});

			form.on("submit(search)",function(data){
				roleRefreshForm();
			})

			//弹出
			$(document).ready(function(){
				msg = $("#_flashmsg_").text()
				if(msg){
					layer.msg(msg, {time:3*1000,icon: 1});
				}
			})
		});
	</script>

</html>
{{end}}